/*	Extends BehaviorController by adding functionality for child behaviors to the current
	behavior.

	Original credit for a java implementation to: http://magicscrollsofcode.blogspot.com/2010/12/behavior-trees-by-example-ai-in-android.html

*/

#ifndef PARENTBEHAVIORCONTROLLER_H_
#define PARENTBEHAVIORCONTORLLER_H_

#include "BehaviorController.h"
#include <vector>

class ParentBehaviorController : public BehaviorController
{
public:
	ParentBehaviorController(BaseBehavior* incBehavior)  : BehaviorController(incBehavior), curPos(0)	{}		

	~ParentBehaviorController();

	/**
	* Append a new subBehavior to our list.
	*/
	void Add(BaseBehavior* incBehavior)		{	subBehaviors.push_back(incBehavior);	}
	
	std::vector<BaseBehavior*>* GetSubBehaviors()	{	return &subBehaviors;	}

	BaseBehavior* GetCurrentBehavior();

	int	GetCurrentBehaviorPos()	{	return curPos;	}

	void IterateBehavior()	{	if(++curPos == subBehaviors.size()) curPos = 0;	}

	void SetCurrent(int incPos)	{	curPos = incPos; }

	void SetCurrent(BaseBehavior* incBehavior);
	/**
	 * Marks the behavior as just started.
	 */
	void Reset();

private:
	/**
	* List of subBehaviors
	*/
	std::vector<BaseBehavior*> subBehaviors;

	/**
	* Current behavior
	*/
	int curPos;


};

#endif
